package com.kungfuhacking.wristbandpro.my.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.kungfuhacking.wristbandpro.R;
import com.kungfuhacking.wristbandpro.base.view.BaseActivity;
import com.kungfuhacking.wristbandpro.custom.TitleBarView;

/**
 * 添加老人页面
 * Created by Aaron on 17/5/15.
 */

public class AddOldActivity extends BaseActivity implements View.OnClickListener {

    private boolean cancle = true;//是否可以返回到上层页面 (true 可以返回  ,  false 不可返回)

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_add_old);
        if (bundle != null) {
            cancle = bundle.getBoolean("cancle");
        }
        initWidget();

    }

    private void initWidget() {
        TextView tvCreatebabySpace = (TextView) findViewById(R.id.tvCreatebabySpace);
        TextView tvEntrybabyCode = (TextView) findViewById(R.id.tvEntrybabyCode);

        TitleBarView tbv = (TitleBarView) findViewById(R.id.tbv);
        tbv.setOnLeftClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!cancle) {
                    showErr("请先添加老人");
                    return;
                }
                finish();
            }
        });

        tvCreatebabySpace.setOnClickListener(this);
        tvEntrybabyCode.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {

        switch (v.getId()) {

            case R.id.tvCreatebabySpace://创建新空间
                nextActivity(CreateSpaceActivity.class);
                break;

            case R.id.tvEntrybabyCode://输入邀请码
                nextActivity(EntryCodeActivity.class);
                break;

        }
    }

    @Override
    public void onBackPressed() {

        if (!cancle) {
            showErr("请先添加老人");
            return;
        }
        super.onBackPressed();
    }
}
